<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet"  th:href="@{/css/file.css}" />
    <script th:src="@{/js/jquery-3.1.1.min.js}"></script>
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
</head>
<body>
<br><br>
<form class="layui-form" th:action="@{/stu/course/pdf/addsubmit}" method="post" enctype="multipart/form-data">
    <div class="layui-form-item">
        <label class="layui-form-label">所属课程名</label>
        <div class="layui-input-inline">
            <select name="course_id" lay-verify="required">
                <option value=""></option>
                <option th:each="test:${topics}" th:value="${test.getId()}" th:text="${test.getCourse_name()}"></option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资料名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline">
            <a href="javascript:;" class="file">格式.pdf
                <input type="file" name="pdf_dto" required lay-verify="required|pdf" autocomplete="off" id="course_image">
            </a>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit  id="layui-submit" type="submit">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        form.verify({
            pdf: function (value, item) {
                if (!/\.(pdf|PDF)$/.test(value)) {
                    return 'pdf格式错误';
                }
            }
        })
    });

    $(document).ready(function () {
        $('#layui-submit').click(function () {
            var ii = layer.load();
        })
    })
</script>
</html>